<!DOCTYPE HTML>
<html>
<head>
    {include file="common_header"}

    <title>添加文章</title>
    <style>
        .anchorBL>a{
            display: none !important;
        }
        .anchorBL>span{
            display: none !important;
        }

    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="__ACSS__bootstrap.css"/>
</head>
<body>
<div class="page-container">
    <form action="{:Url('edit')}" method="post" class="form form-horizontal" id="form">
        <input type="hidden" class="input-text" value="{$data['id']}" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>商家账号：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" value="{$data['shop_username']}" placeholder="" id="articletitle"  maxlength="15"   name="shop_username" datatype="*" nullmsg="文章标题为空！">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">商家logo：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="file" class="input-text" value="" placeholder="" id="articletitle2" name="coverFile">
            </div>
            {if condition="$data['shop_logo']"}
            已上传，<a href="javascript:void(0);"  onclick="previewPictures('__UPS__'+'{$data.shop_logo}')" style="color: red;text-decoration: none;">预览</a>
            {/if}
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>商户经营类别：</label>
            <div class="formControls col-xs-8 col-sm-10">
                 <select  name="classify_id[]"   title="请选择经营类别" id="selectpicker"  class="selectpicker form-control " multiple data-live-search="false">
                     {php}$ids=explode(',',$data['classify_id']);{/php}
                      {volist name=":getlists('classify')" id="v"}
                            <option value="{$v['id']}" {if condition="in_array($v['id'],$ids)"}selected{/if}>{$v['classify_name']}</option>
                      {/volist}
                 </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>商户名称：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" value="{$data['shop_name']}" placeholder=""   maxlength="30"    name="shop_name" datatype="*" nullmsg="文章标题为空！">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>商户联系人：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" value="{$data['shop_person']}" placeholder="请输入商户联系人"  maxlength="20"   name="shop_person" datatype="*" nullmsg="文章标题为空！">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>商户联系电话：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" class="input-text" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" value="{$data['shop_tel']}" placeholder="请输入手机号" maxlength="11"  name="shop_tel" datatype="m" nullmsg="请输入手机号" errormsg="请输入正确的手机号">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>所属省：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <span class="select-box">
                    <select name="shop_pid"  id="shoppid"  class="select" datatype="*" nullmsg="请选择省" >
                       <option disabled selected value="0">请选择省</option>
                        {volist name=":getlists('province')" id="v"}
                              <option value="{$v['id']}" {if condition="$v['id'] eq 1" }selected{/if}>{$v['p_name']}</option>
                        {/volist}
                     </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>所属市：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <span class="select-box">
                    <select name="shop_cid" id="shopcid"  class="select" datatype="*" nullmsg="请选择市" >
                        {volist name=":getlists('city')" id="v"}
                              <option value="{$v['id']}" {if condition="$v['id'] eq 1" } selected{/if}>{$v['c_name']}</option>
                        {/volist}
                     </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>所属县区：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <span class="select-box">
                   <select name="shop_aid"  id="shopaid" class="select" datatype="*" nullmsg="请选县区" onchange="solution(1)" >
                            <option disabled selected value="0">请选县区</option>
                        {volist name=":getlists('area')" id="v"}
                              <option value="{$v['id']}"  {if condition="$v['id'] eq  $data['shop_aid']" } selected{/if}>{$v['a_name']}</option>
                        {/volist}
                   </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1"><span class="c-red">*</span>详细地址:</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" id="address" value="{$data['shop_address']}"  name="shop_address" datatype="*" nullmsg="详细地址不能为空！">
            </div>
            <div class="formControls col-sm-2">
              <button class="btn btn-primary radius" type="button" onclick="solution(2)">定位</button>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">定位坐标：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <input type="text" id="loction" name="shop_location"  class="input-text" value="{$data['shop_location']}">

            </div>
        </div>      <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">商家地图：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <div id="map" class="map" style="height:500px;width: 100%"></div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">商家简介：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <textarea name="shop_intro" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*"  nullmsg="文章摘要不能为空！" >{$data['shop_intro']}</textarea>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-1">商家详情：</label>
            <div class="formControls col-xs-8 col-sm-10">
                <textarea  id="content" name="shop_content" cols="30" rows="10" style="width:100%;height:400px;">{$data['shop_content']}</textarea>
                <!--<script id="editor" type="text/plain" style="width:100%;height:400px;"></script>-->
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-10 col-xs-offset-4 col-sm-offset-1">
                <button class="btn btn-primary radius" type="submit"> 提交审核</button>
            </div>
        </div>
    </form>
</div>
{include file="common_footer"}

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=KisQvBv8QGvf9IpIGfA2rkudfCfZND6V"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.10.0/js/bootstrap-select.min.js"></script>
</body>
<script type="text/javascript">
    $(function () {
        UE.getEditor('content');
        maps();
    });
//    $('.selectpicker').selectpicker({
//        noneSelectedText: '请选择经营类别' //默认显示内容
//    });

    var paddress =jQuery("#shoppid  option:selected").text();
    var caddress =jQuery("#shopcid  option:selected").text();
    var map = new BMap.Map("map");
    var point = new BMap.Point();//地图初始位置
    map.centerAndZoom(point,12);//默认地图级别12级
    map.setDefaultCursor("url('bird.cur')");   //设置地图默认的鼠标指针样式
    map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
    var myGeo = new BMap.Geocoder();
    function maps(){
        var addres="{$data['shop_address']}";
        if(!addres){
            $('#address').val(paddress+caddress);
        }else{
            $('#address').val(addres);
        }
        //单击获取点击的经纬度;
        var myGeo = new BMap.Geocoder();
        map.addEventListener("click",function(e){
            $('#location').val(e.point.lng + ", " + e.point.lat);
            map.clearOverlays();
            var x = e.point.lng;
            var y = e.point.lat;
            var ggPoint = new BMap.Point(x,y);
            map.addControl(new BMap.NavigationControl());
            var markergg = new BMap.Marker(ggPoint);
            map.addOverlay(markergg); //添加GPS坐标
            var labelgg = new BMap.Label("",{offset:new BMap.Size(2,2)});
            markergg.setLabel(labelgg); //添加GPS label
            map.setDefaultCursor("url('bird.cur')");     //设置鼠标形状为手型
            var pt = e.point;
            myGeo.getLocation(pt, function(rs){
                var addresses=rs.address;
                $('#address').val(addresses);
                $('#loction').val(rs.point.lng+','+rs.point.lat);
            });
        });
        if("{$data['shop_location']}"){
            solution(2);
        }else{
            solution(3);
        }
    }
     var locaddress="";
    function solution(type){
        var aaddress =jQuery("#shopaid  option:selected").text();
        if(type==1){
            locaddress=paddress+caddress+aaddress;
            $('#address').val(locaddress);
        }else if(type==2){
            locaddress= $('#address').val();
        }else{
            locaddress=paddress+caddress;
        }
        map.clearOverlays();
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint(locaddress, function(point){
            if (point) {
                map.centerAndZoom(point, 16);
                map.addOverlay(new BMap.Marker(point));
             $('#loction').val(point.lng+','+point.lat);
            }else{
                layer.msg("您选择地址没有解析到结果!");
            }
        }, "北京市");
    }
</script>
</html>